//
// Created by Administrator on 2023/5/28.
//


#include "../header/LDF_Dialog.h"


LDF_Dialog::LDF_Dialog():
        client(new Client(this)), c_b(new Close_Button(this)), max_b(new Max_Button(this, true)), mini_b(new Mini_Button(this, true))
        , wm(new Widget_Move(this))
{
    this->Profile();


    this->client->Redraw();
    this->c_b->Redraw();
    this->max_b->Redraw();
    this->mini_b->Redraw();
}


LDF_Dialog::~LDF_Dialog()
{
    delete client, c_b, max_b, mini_b, wm;
}


void LDF_Dialog::Profile()
{
    this->setWindowFlags(Qt::FramelessWindowHint);
    this->setAttribute(Qt::WA_TranslucentBackground);
    this->setAttribute(Qt::WA_DeleteOnClose, true);
    this->resize(this->width, this->height);
    this->move((DESKTOP_WIDTH - this->width) / 2, (DESKTOP_HEIGHT - this->height) / 2);


    this->setMinimumSize(this->width, this->height);


    this->setMouseTracking(true);
}


QPoint LDF_Dialog::Size()
{
    QPoint size(this->width, this->height);
    return size;
}


Client<LDF_Dialog>* LDF_Dialog::Get_Client()
{
    return this->client;
}


void LDF_Dialog::Widget_Mini()
{
    this->showMinimized();
}


void LDF_Dialog::mouseMoveEvent(QMouseEvent* event)
{
    this->wm->mouseMoveEvent(event);
}


void LDF_Dialog::mousePressEvent(QMouseEvent* event)
{
    this->wm->mousePressEvent(event);
}


void LDF_Dialog::mouseReleaseEvent(QMouseEvent* event)
{
    this->wm->mouseReleaseEvent(event);
}


void LDF_Dialog::paintEvent(QPaintEvent *event)
{
    QPainter main_widget_painter(this);
    main_widget_painter.setRenderHint(QPainter::Antialiasing);
    main_widget_painter.setBrush(QColor::fromRgb(10, 10, 10));

    QRect rect = this->rect();
    main_widget_painter.drawRoundedRect(rect,10,10);

}



